<admintpl file="header" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/ueditor/third-party/video-js/video-js.min.css"/>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/third-party/video-js/video.js"></script>
<script src="http://cdn.bootcss.com/html5media/1.1.8/html5media.min.js"></script>
<script src="http://api.html5media.info/1.1.4/html5media.min.js"></script>
<style>
	.remove{width:700px;height:40px;margin-top:20px;}
	.span3{ width: 700px!important;}N
	.addHtml{margin-top:20px;overflow:hidden;}
	.span3 div:first-child {margin-top:0px}
	.span3 div:first-child a{display:none}



</style>
</head>
<body>

<div class="wrap">
	<form method="post" class="form-horizontal" id="pub_form" action="{$action_url}"
		  enctype="multipart/form-data">

		<div class="control-group">
			<label class="span2 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp投票标题：</label>
			<div class="span7">
				<input type="text" name="title" style="width: 556px;" value="{$news_info.title}">
			</div>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp投票设置：</label>
			<div class="span3 inline" style="width: 80%;display: inline-block">
				<span style="margin-right: 5px">每天注册用户</span><input type="text" name="vote_num"  style="width: 56px;" value="{$news_info.vote_num}"><span style="margin-left: 5px">票</span>
			</div>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">投票设置：</label>
			<div class="span3 inline" style="width: 80%;display: inline-block">
				<span style="margin-right: 5px">投票完成赠送汇闻币</span><input type="text" name="huiwenbi"  style="width: 56px;" value="<?php if($news_info['huiwenbi']){echo $news_info['huiwenbi'];}else{echo 0;}?>"><span style="margin-left: 5px"></span>
			</div>
		</div>


		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp封面图片：</label>
			<div class="span4 wrapper">
				<div id="uploader-image">
					<div id="fileList" class="uploader-list">
						<div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
							<?php
										if(!empty($news_info['cover_image'])){
									?>
							<img id="imagePreview" src="{$news_info.cover_image}" style="width:150px;height: 140px;">
							<?php
										}else{
										?>
							<img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:150px;height: 140px;">
							<?php
										}
										?>
							<div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
							<input style="display:none;" type="file" id="imageFile" name="imageFile" >
						</div>
					</div>
				</div>
			</div><div style="color:red;float:left;margin-top:140px">*尺寸：1110*500  格式：JPG/PNG</div>
		</div>

		<div class="control-group">
			<label class="span2 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp摘要：</label>
			<div class="span7">
				<textarea style="width: 556px; height: 60px;" name="abstract" id="abstract">{$news_info.abstract}</textarea>
			</div>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp开始时间：</label>
			<div class="span4">
				<input type="text" name="start_time" class="js-datetime"  value="<?php if($news_info['start_time']){ ?>{$news_info['start_time']|date="Y-m-d H:i:s", ###}<?php } ?>" autocomplete="off">
			</div>
		</div>
		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp结束时间：</label>
			<div class="span4">
				<input type="text" name="end_time" class="js-datetime"  value="<?php if($news_info['start_time']){ ?>{$news_info['end_time']|date="Y-m-d H:i:s", ###}<?php } ?>" autocomplete="off">
			</div>
		</div>


		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">主办单位：</label>
			<?php if(is_array($news_info['host']) && count($news_info['host']) > 0){ ?>
				<div class="span3"  id="zhuban">
					<?php foreach($news_info['host'] as $k=>$v){ ?>
					<div class="addHtml">
						<input type="text" name="zhuban_name[]" style="width: 556px;" value="{$v}">
						<a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a>
						<a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml1()">添加+</a>
					</div>
					<?php } ?>
				</div>
			<?php }else{ ?>
				<div class="span3"  id="zhuban">
					<input type="text" name="zhuban_name[]" style="width: 556px;" value="">
				</div>
			<?php } ?>
			<a style="font-size: 20px; display: block; float: left;margin-left: -115px;" onclick="copyHtml1()">添加+</a>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">承办单位：</label>
			<?php if(is_array($news_info['contractors']) && count($news_info['contractors']) > 0){ ?>
				<div class="span3"  id="chengban">
					<?php foreach($news_info['contractors'] as $k=>$v){ ?>
					<div class="addHtml">
						<input type="text" name="chengban_name[]" style="width: 556px;" value="{$v}">
						<a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a>
						<a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml2()">添加+</a>

					</div>

					<?php } ?>
				</div>
			<?php }else{ ?>
				<div class="span3"  id="chengban">
					<input type="text" name="chengban_name[]" style="width: 556px;" value="">
				</div>
			<?php } ?>
			<a style="font-size: 20px; display: block; float: left;margin-left: -115px;" onclick="copyHtml2()">添加+</a>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">投票项：</label>
			<?php if(is_array($news_info['vote']) && count($news_info['vote']) > 0){ ?>
				<div class="span3" id="vote">
					<?php foreach($news_info['vote'] as $k=>$v){ ?>
					<div class="addHtml">
						<input type="text" name="vote[]"  style="width: 556px; margin-top: 10px;" value="{$v}">
						<a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a>
						<a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml3()">添加+</a>
					</div>
					<?php } ?>
				</div>
			<?php }else{ ?>
				<div class="span3" id="vote">
					<input type="text" name="vote[]"  style="width: 556px;" value="">
				</div>
			<?php } ?>
			<a style="font-size: 20px; display: block; float: left;margin-left: -115px;" onclick="copyHtml3()">添加+</a>
		</div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;"><span style="color: red; font-size: 8px;">*</span>&nbsp添加组：</label>
			<?php if(is_array($all_group) && count($all_group) > 0){ ?>
				<div class="span3"  id="group">
					<?php foreach($all_group as $k=>$v){?>
						<div class="remove">
						<input type="text" name="group[<?php echo $v['class_id'];?>]" class="group_arr" style="width: 556px;" value="<?php echo $v['class_name'];?>" class="aaa">
						<?php if($k >= 1){ ?>
							<a style="font-size: 20px;padding-left: 10px;" id="<?php echo $v['class_id'];?>" onclick="removeHtml2(this, 1)">删除</a>
							<a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml4()">添加+</a>
						<?php } ?>
					</div>
					<?php } ?>
				</div>
			<?php }else{ ?>
				<div class="span3"  id="group">
					<input type="text" name="group[]" class="group_arr" style="width: 556px;" value="" class="aaa">
				</div>
			<?php } ?>
			<a style="font-size: 20px; display: block; float: left;margin-left: -115px;" onclick="copyHtml4()">添加+</a>
		</div>

	<div class="form-actions" style="padding-left:260px;">
	<input type="hidden" name="img_url" value="{$news_info.cover_image}">
	<button type="button" id="quick_publish" class="btn">下一步</button>
</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>

<script type="text/javascript" >
    $(function() {

    });

    function copyHtml1(){
		var str = '<div class="remove"><input type="text" name="zhuban_name[]"  style="width: 556px; " value="">';
		str += '<a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a><a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml1()">添加+</a></div>';
        $('#zhuban').append(str);
    }
    function removeHtml1(dom) {
		$(dom).parent().remove();
    }

    function removeHtml2(dom, model) {
        if(model == 1){
            var id = dom.id;
            if(!id){
                alert('错误');
                return;
            }

            $.post("{:U('Vote/delGroup')}", {id: id}, function (res) {
                var ret = eval(res);
                if(ret.code == 200){
                    $(dom).parent().remove();
                }else{
                    alert(res.msg);
                }
            }, 'json')
		}else{
            $(dom).parent().remove();
		}
    }

    function copyHtml2(){
		var str = '<div class="remove"><input type="text" name="chengban_name[]" style="width: 556px; margin-top: 0px;" value=""><a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a><a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml2()">添加+</a></div>';
        $('#chengban').append(str);
	}

	function copyHtml3(){
        var str = '<div class="remove"><input type="text" name="vote[]"  style="width: 556px;" value=""><a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml1(this)">删除</a><a style="font-size: 20px;margin-left: 10px; " onclick="copyHtml3()">添加+</a></div>';
        $('#vote').append(str);
	}

    function copyHtml4(){
        var str = '<div class="remove"><input type="text" name="group[]" class="group_arr" style="width: 556px;" value="" class="aaa"><a style="font-size: 20px;padding-left: 10px;" onclick="removeHtml2(this, 0)">删除</a><a style="font-size: 20px;margin-left: 10px;" onclick="copyHtml4()">添加+</a></div>'
	    $('#group').append(str);
    }

    $(".picker").click(function(){
        $(this).siblings('.group_img').click();
//        $(".group_img").click();
    });
//    function fff(id) {
//        $('.group_img'+id).click();
//    }
    $(".group_img").change(function(){
        image_change('group_img', 'img_yulan');
    });

    function insertHtml() {
        var value = prompt('插入html代码', '');
        var s = value.indexOf(".mp4") ;
        var img_video = $("#img_video").val();
        if(s == -1){ //不是 mp4格式的
            value = value;
        }else{
            value = '<video src="'+value+'" style="width:100%" controls="controls" autoplay="autoplay" poster="'+img_video+'" class="videoplay"><\/video>';
        }
        UE.getEditor('content').execCommand('insertHtml', value)
    }

    function html5Reader(file, previewId){
        var file = file.files[0];
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#'+previewId).attr('src', this.result);
        }
    }
    function image_change(fileId, previewId) {
        if($('#'+file)){
            var pic = document.getElementById(previewId)
		}else {
            var pic = document.getElementByClass(previewId)
		}
//        var pic = document.getElementById(previewId),
            var file = document.getElementById(fileId);
//        file = $('#img_yulan').html();
        console.log(pic)
        console.log(file)
        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();
		console.log(ext)
        // gif在IE浏览器暂时无法显示
        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
            alert("图片的格式必须为png或者jpg或者jpeg格式！");
            return;
        }
        var isIE = navigator.userAgent.match(/MSIE/)!= null,
            isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

        if(isIE) {
            file.select();
            var realLocalPath = document.selection.createRange().text;

            // IE6浏览器设置img的src为本地路径可以直接显示图片
            if (isIE6) {
                pic.src = realLocalPath;
            }else {
                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
                pic.src = '';
            }
        }else {
            html5Reader(file, previewId);
        }
    }

    $("#picker").click(function(){
        $("#imageFile").click();
    });

    $("#imageFile").change(function(){
        image_change('imageFile', 'imagePreview');
    });
</script>
</body>
</html>